<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico" >
<link rel="Shortcut Icon" href="favicon.ico" />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui/css/H-ui.min.css') }}"/>
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui.admin/css/H-ui.admin.css') }}" />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/lib/Hui-iconfont/1.0.8/iconfont.css') }}"  />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui.admin/skin/default/skin.css') }}"  id="skin" />
<link rel="stylesheet" type="text/css" href="{{ URL::asset('/admin/h-ui.admin/css/style.css') }}" />

</head>
<body>
<article class="cl pd-20">
	<form action="/admin/admin/editAdmin" method="post" class="form form-horizontal" id="form-admin-edit">
		{{ csrf_field() }}
		<input type="hidden" name="id" value="{{ $user['id'] }}">
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>管理员账号：</label>
			<div class="formControls col-xs-10 col-sm-10">
				<input type="text" class="input-text" value="{{ $user['name'] }}" placeholder="" id="name" name="name" datatype="*4-16">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>修改密码：</label>
			<div class="formControls col-xs-10 col-sm-10">
				<input type="password" class="input-text" value="" placeholder="" id="password" name="password" datatype="*4-16">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>确认密码：</label>
			<div class="formControls col-xs-10 col-sm-10">
				<input type="password" class="input-text" value="" placeholder="" id="password2" name="password2" datatype="*4-16">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>角色：</label>
			<div class="formControls col-xs-10 col-sm-10"> 
				<span class="select-box" style="width:150px;">
					<select class="select" name="groupid" size="1" required>
						@foreach($groups as $k)
						<option value="{{ $k['id'] }}" 
							@if($k['id'] == $user['groupid']) selected = 'selected'  
							@endif>
							{{ $k['title'] }}
						</option>
						@endforeach
					</select>
				</span> 
			</div>
		</div>
		
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-success radius"><i class="icon-ok"></i>修改</button>
			</div>
		</div>
	</form>
</article>


<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery/1.9.1/jquery.min.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/lib/layer/2.4/layer.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('/admin/h-ui/js/H-ui.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/h-ui.admin/js/H-ui.admin.page.js') }}"></script> 
<!--/_footer /作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery.validation/1.14.0/jquery.validate.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery.validation/1.14.0/validate-methods.js') }}"></script> 
<script type="text/javascript" src="{{ URL::asset('/admin/lib/jquery.validation/1.14.0/messages_zh.js') }}"></script> 
<script type="text/javascript">
$(function(){
	$("#form-admin-edit").validate({
		rules:{
			name:{
				required:true,
			},
			password:{
				required:true,
			},
			password2:{
				required:true,
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			let pass1 = $('#password').val();
			let pass2 = $('#password2').val();
			if(pass1 !== pass2){
				layer.msg('两次密码输入不一致!');
				return false;
			}
			$(form).ajaxSubmit(function(call){
				// console.log(index);
				if (call == 1) {
					layer.msg('修改成功!',{icon:1,time:1000},function(){
						//加载刷新父类页面并关闭弹窗
						window.parent.location.reload();
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					});
				} else {
					layer.msg(call,{icon:2,time:50000});
					return false;
				}
			});
		}
	});
});
</script>
</body>
</html>